#!/bin/sh

# $Id$

# simple startup script to create lvm2 devices if /dev is a mountpoint, there
# are active dm- devices, and an executable /sbin/vgscan.

# this script is licensed under GPLv2.
# See http://www.gnu.org/licenses/gpl.html

case $1 in
start)
    # is /dev a mountpoint?
    mountpoint -q /dev
    DEVMNTPOINT=$?

    # check to see if there are active dm entries under /sys
    ls /sys/block/dm-*/dev 1>/dev/null 2>&1
    ACTIVEDMDEVS=$?

    # mknodes if conditions are right
    if [ $DEVMNTPOINT -eq 0 -a $ACTIVEDMDEVS -eq 0 -a -x /sbin/vgscan ]; then
        /sbin/vgscan --mknodes --ignorelockingfailure
    fi
    ;;
stop)
    exit 0
    ;;
*)
    echo "usage:"
    echo "    $0 start|stop"
    ;;
esac
